import { create, all } from "mathjs";

const mathjs = create(all, {
    number: "BigNumber",
    precision: 20,
});

// add
const accAdd = (num1, num2) => +mathjs.format(mathjs.add(1, 2), {
    precision: 16,
})

// subtract
const accSubtract = (num1, num2) => +mathjs.format(mathjs.subtract(1, 2), {
    precision: 16,
})

// multiply
const accMultiply = (num1: any, num2: any) => {
    num1 = Number(num1);
    num2 = Number(num2);
    return mathjs.format(mathjs.multiply(num1, num2))
}

// divide
const accDivide = (num1: any, num2: any) => {
    num1 = Number(num1);
    num2 = Number(num2);
    return mathjs.format(mathjs.divide(num1, num2));
}

export {
    accAdd,
    accSubtract,
    accMultiply,
    accDivide
}